package com.nwpu.main;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 * RMIServer
 *
 * @author 龙虹宇
 * @version 1.0
 * @date 2023/11/1
 */
public class RMIServer {
    // 默认 RMIRegistry 端口
    private static final int PORT = 1099;
    // 默认IP
    private static final String IP = "127.0.0.1";

    public static void main(String[] args) {

        try {
            // 创建RMIRegistry
            Registry registry = LocateRegistry.createRegistry(PORT);
            // 创建方法类
            IMethodSet methodSet = new MethodSetImpl(PORT, IP);
            // 绑定stub存根
            registry.bind("methodSet", methodSet);
            System.out.println("==服务器已启动==");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
